Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix VB Conversions #31486

Merged
merged 3 commits into from
Oct 2, 2018
Merged

Fix VB Conversions #31486

merged 3 commits into from
Oct 2, 2018

Conversation

hughbe
Copy link

@hughbe hughbe commented Jul 30, 2018


End Function

<CLSCompliant(False)>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove any CLSCompliant attributes. We don't use them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I get various errors if I do this though:

"C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\Microsoft.VisualBasic.sln" (default target) (1) ->
"C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\tests\Microsoft.VisualBasic.Tests.csproj.metaproj" (d
efault target) (2) ->
"C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj.metaproj" (default t
arget) (3) ->
"C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj" (default target) (5
) ->
(CoreCompile target) ->
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(322,32): error BC40027: Return type of function 'ToSByte' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub\
corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(343,32): error BC40027: Return type of function 'ToSByte' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub\
corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(613,32): error BC40027: Return type of function 'ToUShort' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub
\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(634,32): error BC40027: Return type of function 'ToUShort' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub
\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(899,32): error BC40027: Return type of function 'ToUInteger' is not CLS-compliant. [C:\Users\hughb\Documents\GitH
ub\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(920,32): error BC40027: Return type of function 'ToUInteger' is not CLS-compliant. [C:\Users\hughb\Documents\GitH
ub\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(1189,32): error BC40027: Return type of function 'ToULong' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub
\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(1212,32): error BC40027: Return type of function 'ToULong' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub
\corefx\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(2201,55): error BC40028: Type of parameter 'Value' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub\corefx\
src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]
  C:\Users\hughb\Documents\GitHub\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Conversio
ns.vb(2209,55): error BC40028: Type of parameter 'Value' is not CLS-compliant. [C:\Users\hughb\Documents\GitHub\corefx\
src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.vbproj]

    0 Warning(s)
    10 Error(s)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OK fair enough

NumberStyles.AllowTrailingWhite Or
NumberStyles.AllowCurrencySymbol


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, there are various double newlines in this file

Return Value.ToString()

Public Shared Function FromCharArraySubset(ByVal Value() As Char, ByVal StartIndex As Integer, ByVal Length As Integer) As String
' This is a private function used from the debug windows (VS7 264234)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove references to old bug databases eg (VS7 264234) .. VS7 = Visual Studio 2002 ... I doubt any of us could find that bug database any more.

{
Assert.Throws<InvalidOperationException>(() => Conversions.ToChar(value));
}

private static object s_floatEnum;

public static object FloatEnum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't make a float enum in VB or C#. Is it worth bothering to test this scenario? Ref.Emit is nice to avoid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for bool and char. I would just skip them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These edge cases used to throw a different exception in .NET Core compared to .NET Framework or threw when netfx didn't, so I would advocate keeping them. No harm really and there are already tests dotted around the place that use IntPtr/float etc. enums

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@karelz
Copy link
Member

karelz commented Sep 5, 2018

@danmosemsft is there anything left from your side?
@cston @333fred @jaredpar can you please review and merge?

yield return new object[] { char.MinValue };
yield return new object[] { (char)1 };
yield return new object[] { char.MaxValue };
yield return new object[] { new DateTime(10) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these cases no longer relevant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they’re consolidated with the test data for other methods as they’re common with all other conversion methods

@danmoseley
Copy link
Member

Do you want to rebase @hughbe then we can probably merge?

@karelz karelz added this to the 3.0 milestone Sep 6, 2018
@ViktorHofer
Copy link
Member

@dotnet-bot test this please

@karelz
Copy link
Member

karelz commented Oct 2, 2018

@cston @333fred can you please merge it?

@333fred
Copy link
Member

333fred commented Oct 2, 2018

@hughbe when I merge this I would like to squash the commits, do you have a problem if I do that on my end? Or would you prefer to manually squash them yourself?

@karelz
Copy link
Member

karelz commented Oct 2, 2018

@333fred please squash it, that's what we do, unless there is strong reason to keep the PR change history.

@danmoseley
Copy link
Member

+1, in CoreFX and CoreCLR we always "squash and merge" unless there's good reason - I know other repos have different policies.

@cston cston merged commit 87ca813 into dotnet:master Oct 2, 2018
@cston
Copy link
Member

cston commented Oct 2, 2018

Thanks @hughbe, this has been merged.

@hughbe hughbe deleted the vb-conversion-fixes branch October 2, 2018 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants